/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.pojo.sqlServer;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
* @website https://eladmin.vip
* @description /
* @author xinglin
* @date 2024-08-03
**/
@Entity
@Data
@Table(name="pp_task_result")
public class PPTaskResult implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "id")
    private Integer id;

    @Column(name = "`wms_task_id`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "任务id")
    private String wmsTaskId;

    @Column(name = "`wcs_task_type`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "任务类型")
    private Integer wcsTaskType;

    @Column(name = "`lpn_code`")
    @ApiModelProperty(value = "容器编码")
    private String lpnCode;

    @Column(name = "`from_location`")
    @ApiModelProperty(value = "实际取货地址")
    private String fromLocation;

    @Column(name = "`to_location`")
    @ApiModelProperty(value = "实际送货地址")
    private String toLocation;

    @Column(name = "`created`")
    @ApiModelProperty(value = "实际完成时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
    private LocalDateTime created;

    @Column(name = "`status`")
    @ApiModelProperty(value = "任务状态")
    //0-初始 1-取货完成 2-任务完成（放货完成）3-异常
    private Integer status;

    @Column(name = "`issue_code`")
    @ApiModelProperty(value = "错误代码")
    private Integer issueCode;

    @Column(name = "`message`")
    @ApiModelProperty(value = "异常原因")
    private String message;

    @Column(name = "`last_updated`")
    @ApiModelProperty(value = "最后更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
    private LocalDateTime lastUpdated;

    public void copy(PPTaskResult source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
